from django.db import models
from django.utils import timezone

class Question(models.Model):
    question_text = models.CharField(
        max_length=200,
        help_text="问题的具体文本内容"
    )
    pub_date = models.DateTimeField(
        "date published",
        default=timezone.now,
        help_text="问题发布的日期"
    )
    is_deleted = models.BooleanField(
        default=False,
        help_text="软删除标记 (True表示已删除)"
    )

    def __str__(self):
        return self.question_text

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(
        max_length=200,
        help_text="选项的文本内容"
    )
    votes = models.IntegerField(
        default=0,
        help_text="该选项获得的票数"
    )

    def __str__(self):
        return self.choice_text